<!DOCTYPE html>
<html lang="zh" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('商品审核列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>


                        <li>
                            <p>搜索关键词：</p>
                            <input name="name" type="text"/>
                        </li>
                        <li>
                            <p>审核状态：</p>
                            <select name="verifyStatus">
                                <option value="">所有</option>
                                <option value="0">审核中</option>
                                <option value="1">审核通过</option>
                                <option value="2">审核不通过</option>
                            </select>
                        </li>

                        <li>
                            <p>开始时间：</p>
                            <input name="startTime" type="text"/>
                        </li>

                        <li>
                            <p>结束时间：</p>
                            <input name="endTime" type="text"/>
                        </li>

                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!-- <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="mall:store:add">
                 <i class="fa fa-plus"></i> 添加
             </a>
             <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="mall:store:edit">
                 <i class="fa fa-edit"></i> 修改
             </a>
             <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
                shiro:hasPermission="mall:store:remove">
                 <i class="fa fa-remove"></i> 删除
             </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="mall:store:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table data-mobile-responsive="true" id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('mall:store:edit')}]];
    var removeFlag = [[${@permission.hasPermi('mall:store:remove')}]];
    var prefix = ctx + "mall/check";

    console.log(ctx);
    $(function () {
        var options = {
            url: prefix + "/goods/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "店铺",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '编号'
                },
                {
                    field: 'companyName',
                    title: '公司名称'
                },

                {
                    field: 'pic',
                    title: '缩略图',
                    formatter: function (value, row, index) {
                        return '<img src="' + row.pic + '" width="50px" height="50px"> ';
                    }
                },
                {
                    field: 'name',
                    title: '商品名称'

                },
                {
                    field: 'productCategoryName',
                    title: '分类'

                },
                {
                    field: 'price',
                    title: '销售价'

                },
                {
                    title: '状态',
                    field: 'verifyStatus',
                    formatter: function (value, row, index) {

                        if (row.verifyStatus === 0) {
                            return "审核中";
                        } else if (row.verifyStatus === 2) {
                            return "审核不通过";
                        } else {
                            return "审核通过";
                        }
                    }
                },
                {
                    field: 'verifyTime',
                    title: '提交时间'

                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="detailUrl(\'' + row.id + '\')">详情</a>');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="reviewDetailsUrl(\'' + row.id + '\')">审核详情</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    /* 用户状态显示 */
    function statusTools(row) {
        if (row.status === 3) {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disable(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enable(\'' + row.id + '\')"></i> ';
        }
    }

    /* 用户管理-停用 */
    function disable(userId) {
        $.modal.confirm("确认要停用商户吗？", function () {
            $.operate.post(prefix + "/changeStatus", {"id": userId, "status": 1});
        })
    }

    /* 用户管理启用 */
    function enable(userId) {
        $.modal.confirm("确认要启用商户吗？", function () {
            $.operate.post(prefix + "/changeStatus", {"id": userId, "status": 3});
        })
    }

    function boutiQueTools(row) {
        if (row.isBoutique == 0) {
            return '<i class=\"fa fa-toggle-off text-info fa-2x\" onclick="enableBoutiQue(\'' + row.id + '\')"></i> ';
        } else {
            return '<i class=\"fa fa-toggle-on text-info fa-2x\" onclick="disableBoutiQue(\'' + row.id + '\')"></i> ';
        }
    }

    /* 精品标识-停用 */
    function disableBoutiQue(userId) {
        $.modal.confirm("确认要关闭此店铺精品标识吗？", function () {
            $.operate.post(prefix + "/changeStatus", {"id": userId, "isBoutique": 0});
        })
    }

    /* 精品标识启用 */
    function enableBoutiQue(userId) {
        $.modal.confirm("确认要启用此店铺精品标识吗？", function () {
            $.operate.post(prefix + "/changeStatus", {"id": userId, "isBoutique": 1});
        })
    }

    function detailUrl(id) {
        $.modal.open("商品详情", prefix + "/goodsDetail?id=" + id);
    }

    function reviewDetailsUrl(id) {
        $.modal.open("审核详情", prefix + "/vertifyDatail?id=" + id);
    }

</script>
</body>
</html>
